<?php
/**
* 消息数据模型
* @date: 2018年6月5日 上午10:12:44
* @author: xiaocui
*/

namespace app\admin666\validate;

use think\Validate;

class Member extends Validate
{
    protected $rule =  [
        'username'  =>  'require|length:4,20',
        'password' =>  'require|length:6,20',
        'my_point' => 'number|check_point',
    ];
    
    protected $message = [
        'username.require' => '请填写用户名',
        'username.length' => '用户名长度不合法',
        'password.require' => '请填写密码',
        'password.length' => '密码长度不合法',
        'my_point.number' => '提成比例必须是数字',
    ];

    protected $scene = [
        'add' => ['username','password'],
        'add2' => ['username','password','my_point'],
        'edit2' => ['username','my_point'],
    ];
    
    
    protected function check_point($value,$rule,$data)
    {
        $max = intval(config('one_point'));
        if($value < 0 || $value > $max){
            return "提成比例只能在0-{$max}之间";
        }
        return true;
    }
    
}